import { defineStore } from 'pinia'
import { ref ,} from 'vue'
import { get } from '../common/'
export const useCategoryStore = defineStore('category', () => {
  const categoryList = ref([])
  const age=ref(0)
  // let todos = ref<T[]>((JSON.parse(sessionStorage.getItem('todos')||'{"todos":[]}')?.todos)); 
  const getCategory=async()=>{
    try{
      age.value++;
      const res:any=await get('/api/category/list')
    categoryList.value=res.result
    }catch(err){
      console.log(err)
    }
    
  }
  return {
    getCategory,
    categoryList,
    age
  }
},{
  // persist: true, //持久化
  // persist: {
  //   // key:"ids",
  //   storage: sessionStorage,
  //   // pick: ['todos'],
  // }
})